package com.xipu.yygh.manage.controller;

import com.xipu.yygh.common.result.R;
import com.xipu.yygh.manage.service.ScheduleService;
import com.xipu.yygh.model.hosp.Schedule;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * description: 排班信息接口
 * @author: gql
 * @date: 2022/05
 */
@RequestMapping("/admin/hosp/schedule")
@RestController
public class ScheduleController {
    /**
     * 排班信息Service
     */
    @Autowired
    private ScheduleService scheduleService;

    /**
     * 查询排班规则数据-带分页
     * @param page 当前页
     * @param limit 每页记录数
     * @param hoscode 医院编号
     * @param depcode 科室编号
     * @return r
     */
    @GetMapping("getScheduleRule/{page}/{limit}/{hoscode}/{depcode}")
    public R getScheduleRule(@PathVariable("page") long page,
                             @PathVariable("limit") long limit,
                             @PathVariable("hoscode") String hoscode,
                             @PathVariable("depcode") String depcode) {
        Map<String, Object> map
                = this.scheduleService.getRuleSchedule(page, limit, hoscode, depcode);
        return R.ok().data(map);
    }

    /**
     * 查询每日排班详细信息
     * @param hoscode 医院编号
     * @param depcode 科室编号
     * @param workDate 工作日期
     * @return r
     */
    @GetMapping("getScheduleDetail/{hoscode}/{depcode}/{workDate}")
    public R getScheduleDetail(@PathVariable("hoscode") String hoscode,
                               @PathVariable("depcode") String depcode,
                               @PathVariable("workDate") String workDate) {
        List<Schedule> list = this.scheduleService.getDetailSchedule(hoscode, depcode, workDate);
        return R.ok().data("list", list);
    }

}
